$(document).ready(function(){	

	$('#menu-data').hover(

	  function () {

		$('#sub-menu-data').show();

	  },

      function () {

		$('#sub-menu-data').hide('');

	  }		

	);

});

// ============= NbɃSU  =============  //



function setTab(name,num,n){

	for(i=1;i<=n;i++){

		var menu=document.getElementById(name+i);

		var con=document.getElementById(name+"_"+"con"+i);

		menu.className=i==num?"now":"";

  		con.style.display=i==num?"block":"none"; 

	}

}


function setTabnowclass(name,nowclass,num,n){

	for(i=1;i<=n;i++){

		var menu=document.getElementById(name+i);

		var con=document.getElementById(name+"_"+"con"+i);

		menu.className=i==num?nowclass:"";

  		con.style.display=i==num?"block":"none"; 

	}

}




function setTabCont(name,num,n){

	for(i=1;i<=n;i++){

		var menu=document.getElementById(name+i);

		var con=document.getElementById(name+"_"+"con"+i);

		menu.className=i==num?"tnow":"";

  		con.style.display=i==num?"block":"none"; 

	}

}



// ============= Y4TAB  =============  //



$.fn.infiniteCarousel = function () {



    function repeat(str, num) {

        return new Array( num + 1 ).join( str );

    }

  

    return this.each(function () {

        var $wrapper = $('> div', this).css('overflow', 'hidden'),

            $slider = $wrapper.find('> ul'),

            $items = $slider.find('> li'),

            $single = $items.filter(':first'),

            

            singleWidth = $single.outerWidth(), 

            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border

            currentPage = 1,

            pages = Math.ceil($items.length / visible);            





        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items

        if (($items.length % visible) != 0) {

            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));

            $items = $slider.find('> li');

        }



        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first

        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));

        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));

        $items = $slider.find('> li'); // reselect

        

        // 3. Set the left position to the first 'real' item

        $wrapper.scrollLeft(singleWidth * visible);

        

        // 4. paging function

        function gotoPage(page) {

            var dir = page < currentPage ? -1 : 1,

                n = Math.abs(currentPage - page),

                left = singleWidth * dir * visible * n;

            

            $wrapper.filter(':not(:animated)').animate({

                scrollLeft : '+=' + left

            }, 500, function () {

                if (page == 0) {

                    $wrapper.scrollLeft(singleWidth * visible * pages);

                    page = pages;

                } else if (page > pages) {

                    $wrapper.scrollLeft(singleWidth * visible);

                    // reset back to start position

                    page = 1;

                } 



                currentPage = page;

            });                

            

            return false;

        }

        

        $wrapper.after('<a class="arrow back"> </a><a class="arrow forward"> </a>');

        

        // 5. Bind to the forward and back buttons

        $('a.back', this).click(function () {

            return gotoPage(currentPage - 1);                

        });

        

        $('a.forward', this).click(function () {

            return gotoPage(currentPage + 1);

        });

        

        // create a public interface to move to a specific page

        $(this).bind('goto', function (event, page) {

            gotoPage(page);

        });

    });  

};



$(document).ready(function () {



    var autoscrolling = true;

    

    $('.infiniteCarousel').infiniteCarousel().mouseover(function () {

        autoscrolling = false;

    }).mouseout(function () {

        autoscrolling = true;

    });

    

    setInterval(function () {

        if (autoscrolling) {

            $('.infiniteCarousel').trigger('next');

        }

    }, 4000);

});



// ============= W[PnR  =============  //



$(document).ready(function () {

	$("#get-more").click(function(){

		$("#other").toggle().css("line-height","1.8em");

	}); 





});



/*iframe 自适应高度*/
function iFrameHeight() { 
var ifm= document.getElementById("ifrMain"); 
var subWeb = document.frames ? document.frames["ifrMain"].document : ifm.contentDocument; 
if(ifm != null && subWeb != null) { 
ifm.height = parseInt(subWeb.body.scrollHeight)<400?400:subWeb.body.scrollHeight; 
} 
}


/*
*文字输入长度检查，加入对象的onKeyUp 和 ONKEYDOWN 时间中
obj=检查对象id,tips=提示内容显示id,length=允许最大长度
*/

function CharCountCheck(obj,tips,length) {
  var flag=true;	
  var desc_el = document.getElementById(obj);
  var remainingchars_el = document.getElementById(tips);

  var num_remaining =parseInt(length) - desc_el.value.replace(/[^\x00-\xff]/g, "**").length;

  if (num_remaining >= 0) {
  remainingchars_el.innerHTML ="还可输入" +num_remaining+ "字节"
  } else {
	num_remaining=0-num_remaining;   
    remainingchars_el.innerHTML = "<font color=red>超出" +num_remaining + "字节</font>";
	flag=false;
  }
 return flag; 
}

/*
*文字输入长度检查2，在blur事件中调用
obj=检查对象id,tips=提示内容显示id,length=允许最大长度
*/
function BCharCountCheck(obj,length) {
	var sText=document.getElementById(obj);
    var intlen=sText.value.replace(/[^\x00-\xff]/g, "**").length;
    if (intlen>length)  {
        alert("输入字符数不能多于"+length);
         sText.focus();
         sText.select();
      }
  }
